<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container {
            width: 900px;
            height: 200px;
            background-color: pink;
            margin: 50px auto;
            /* 行内元素或者行内块元素水平居中给其父元素添加 text-align:center 即可 */
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="container">
        <span>
            这是一个文字
        </span>
    </div>
    <div class="container">
        <img src="down.jpg" />
    </div>
</body>
</html>